#ifndef __ESP32_SERIAL_H__
#define __ESP32_SERIAL_H__
#include "stdint.h"
#include "ringbuf/softRingBuf.h"
#include "stm32f7xx_hal.h"
#include "stm32f7xx_hal_uart.h" 

typedef struct xySerialType xySerial;










struct xySerialType{
    struct {
        uint32_t sending :1;
        uint32_t :0;
    }stat;
		UART_HandleTypeDef* uart;
		uint32_t baudRate;
    softRingBuf txBuf;
    softRingBuf rxBuf;
    void (*sendStartCallback)(void);
    void (*sendCompleteCallback)(void);
    void (*dataReadyCallback)(uint8_t byte);
		int32_t (*uartInit)(void);
		int32_t (*uartDeInit)(void);
		int32_t (*uartSetBaud)(xySerial* const serial,uint32_t baudRate);
		int32_t (*sendBuf)(xySerial* const serial,uint8_t* pBuf,uint32_t len);
		int32_t (*senfChar)(xySerial* const serial,uint8_t byte);
		int32_t (*getChar)(xySerial* const serial,uint8_t* byte);
		int32_t (*clearBuffer)(xySerial* const serial,uint8_t fifoType);
};


int32_t xySerialInit(xySerial* const serial);



#endif
